package com.example.controller;

import com.example.service.JvmMemoryService;
import com.example.service.JvmStackService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/jvm")
public class JvmOptimizeController {
    @Autowired
    private JvmMemoryService jvmMemoryService;
    @Autowired
    private JvmStackService jvmStackService;


    @GetMapping("/outOfMemoryTest")
    public String outOfMemoryTest(@RequestParam("m")int m){
        jvmMemoryService.outOfMemory(m);
        return "success";
    }
    @GetMapping("/deadLockTest")
    public String deadLockTest(){
        jvmStackService.deadLock();
        return "success";
    }
    @GetMapping("/deadCircle")
    public String deadCircle(@RequestParam("time") long time){
        jvmStackService.deadCircle(time);
        return "success";
    }
}
